/**
 * Created by wdj on 15/11/13.
 */
;(function(hybrid){

    hybrid.plugin.imagePicker = {

        /**
         * 图片选择类型
         */
        SourceType: {
            PhotoLibrary: 0,
            Camera: 1,
            PhotosAlbum: 2,
            Other: -1
        },

        /**
         * 打开图片选择器
         * @param {Object} options
         * @param {Function} callback
         */
        open: function(options ,callback){
            if(!callback) return;
            var self = this;
            options = hybrid.utils.extend({
                title: "选择图片",
                message: "",
                //quality: 100,
                //width: 0,
                editing: false, // 是否启用图片编辑
                sourceType: self.SourceType.Other, // 图片选择类型
                upload: false, // 是否上传到服务器
                uploadFormAction: '', // 上传地址
                uploadFormName: '' //上传表单字段名
            }, options);
            hybrid.callAction('ImagePicker/selectImages', options, function(result){
                typeof callback === 'function' && callback(result.status, result.data);
            });
        }
    };

})(Hybrid || {});
